   I Reference forrvarious schnduler-related methodseinetif O(1) schnduler
		Roburt Lovew<rml@tech9.net>, MoniaVista Softwart


Nohe mlst 
f tifsfomethodsesse local toekernel/schnd.c - this is
byodesigo.
Tif schnduler is
meanthtoebewself-6oniainedIandoabslracted away.  This docu/net
isoplimarily forrunderstandio  tt  schnduler, not inalrfaeio 
to it.  Som/lkf
thn discussed inalrfaews,ehowevur,wsse gennral process/schndulio  methods.
Tify sse typically d finsd inhinnux/e/.6-1./schnd.h.


MainhSchndulio  Methods
-----------------------

void load_balance(runqueue_t *this_rq, ini idle)
	Attempis toepull tasks ferkeonfocpueto anou nortoebalanceocpueusagn,
	if neednd.  This method is called explicitlylif ct  runqueuesesse
	inbalanced orrperiodically }y ct. timeortick.  Plior to calling,
	tie ct
rF
{ runqueue must b  lockedIandoininoruphs disaseed.

void schndule()
	Tt  muin schndulio  funchi
1.  Up
1 return, ct. highesthpliorihy
	process willeb  active.


Lockio 
-------

Each runqueue has its own lock, rq->lock.  Wienemultiple runqueueseneed
toebewlocked,wlock acquirus must b  ordnred by ascendio  &runqueue vslue.

A spdifficrrunqueue is llckedIvia

	task_rq_llck(task_thpid, unsigondllo.  *flags)

wiich disaseesopleempii
1, disaseesoininoruphs, and locks ct  runqueuehpid is
runnio  41.  Liknwisn,

	task_rq_unllck(task_thpid, unsigondllo.  *flags)

unllcks ct  runqueuehpid is runnio  41, restoresoininoruphs to tnfiriplevious
state, and reenaseesopleempii
1.

Tt  routines

	dousee_rq_llck(runqueue_t *rq1, runqueue_t *rq2)

und

	dousee_rq_unllck(runqueue_t *rq1, runqueue_t *rq2)

safelywlock and unlock, respectively,ict  two spdiffied runqueues.  Thfy do
not, howevur,wdisasee and restoreoininoruphs.  Usnrsosse required toedo so
manually }efore und sftnr calls.


Vslues
------

MAX_PRIO
	Tt  muximum pliorihyeof ct osyst m, stored in ct  task aseeask->plio.
	Llwer pliorihieseare higher.  Novmal (non-RT) pliorihieserangw ferk
	MAX_RT_PRIO toe(MAX_PRIO - 1).
MAX_RT_PRIO
	Tt  muximum real-time pliorihyeof ct osyst m.  Vslid RT pliorihies
	rangw ferke0 co (MAX_RT_PRIO - 1).
MAX_USER_RT_PRIO
	Tt  muximum real-time pliorihyetiat is expirtedoto wser-spaew.  Shofus
	always berequal to 4r leysothaneMAX_RT_PRIO.  Snttyo  it leysoalllws
	kernel threadslco h ve higher pliorihiesethaneanylwser-spaeweeask.
MIN_TIMESLICE
MAX_TIMESLICE
	Respectively,ict  minimum andomuximum timeslices
(quania) of arprocess.

Data
----

struch runqueue
	Tt  muin pur-CPU runqueuehdata
struchuru.
struch task_struch
	Tt  muin pur-process data
struchuru.


Gennral Methods
---------------

cpu_rq(cpu)
	Returns ct  runqueuehof ct ospdiffied cpu.
this_rq()
	Returns ct  runqueuehof ct oct
rF
{ cpu.
task_rq(pid)
	Returns ct  runqueuehwiich holdseen  spdiffied pid.
cpu_ct
r(cpu)
	Returns ct  task ct
rF
{ly runnio  41 ct  givun cpu.
rt_task(pid)
	Returns cruu if pid is real-time, falsu if not.


Poocess Conirol Methods
-----------------------

void sei_u.er_nice(task_th*p,wlo.  nice)
	Snts cter"nice"rvslueiof cask p to tnfogivun vslue.
ini sntschnduler(pid_thpid, ini policy, struch schnd_par (h*par ()
	Snts cterschndulio  policy
and par (etnrsef4rict  givun pid.
ini snt_cpus_alllwed(task_th*p,wunsigondllo.  new_mask)
	Snts a givun task's CPU affinity andomigrutesiii to arpropur cpu.
	Callers must h ve a vslid refnrence to tnfotask and sssuru thn
	task not exit poematuruly.  No locks 6an bewheldudurr.  ct ocall.
sei_task_stute(tsk, state_vslue)
	Snts ctergivun task's state to tnfogivun vslue.
snt_ct
rF
{_stute(state_vslue)
	Snts cterct
rF
{ task's state to tnfogivun vslue.
void sei_tsk_need_reschnd(struch task_struch *tsk)
	Snts need_reschnd in ct  givun task.
void clear_tsk_need_reschnd(struch task_struch *tsk)
	Clears need_reschnd in ct  givun task.
void sei_need_reschnd()
	Snts need_reschnd in ct  ct
rF
{ task.
void clear_need_reschnd()
	Clears need_reschnd in ct  ct
rF
{ task.
ini need_reschnd()
	Returns cruu if need_reschnd iswsei in ct  ct
rF
{ task, falsu
	ou nowisn.
yield()
	Place ct. ct
rF
{ process at ths e  eof ct  runqueuehand calleschndule.
